{if $data.comments}
<a name="comments"></a>
{literal}
<script language="Javascript" type="text/javascript">

	function quickreply(tree) {

        //hide big form
        document.getElementById('addComment').style.display = 'none';
        
        var replyForm = document.getElementById('quickAddComment');
		replyForm.style.display = '';
        var currentComment = document.getElementById(tree);

		var replyToField = document.getElementById('quickReplyID');
		replyToField.value = tree;
        
		currentComment.parentNode.insertBefore(replyForm, currentComment.nextSibling);
        document.getElementById('qcom').focus();
        return false;
    }

	function goTo(link){
		window.location.href = link;
	}
</script>
{/literal}

<div id="comments" class="comments-list">

<h2>{#entComments#} {if $data.intime < ($smarty.const.NOW - 60*60*24*$smarty.const.COMMENT_DAYS)}{#disabled#}{/if}</h2>

    

	{foreach from=$comments item=comment name=myComments}

		{*
		{if $comment.deleted}
			{#comDeleted#}
		{else}
		*}
		{if !$comment.deleted}

		    {math equation="x * y" x=$comment.level y=30 assign="indent"}
			{math equation="x * y" x=$smarty.const.COMMENT_TREE_DEPTH y=30 assign="maxIndent"}
		    {if $indent > $maxIndent}
		      {assign var="indent" value=$maxIndent}
		    {/if}

			{math equation="x - y" x=420 y=$indent assign="indent2"}
			{math equation="x * y" x=$smarty.const.COMMENT_TREE_DEPTH y=30 assign="maxIndent2"}
		    {if $indent2 < $maxIndent2}
		      {assign var="indent" value=$maxIndent2}
		    {/if}
			<div class="{cycle values="entry alt,entry"} {if $comment.admin}Reply{/if}" id="comment-{$comment.commentid}" name="comment-{$comment.commentid}" style="margin-left: {$indent}px; ">
				
				
				{if $comment.admin}
					<p class="name"><h4><b>{#authorReply#}</b>&nbsp; on {$comment.intime|date_format:'%d.%m.%Y // %H:%M'} </h4>
				{else}
					{if $comment.senderURL}
						<p class="name"><h4><b><a href="{$comment.senderURL}" target="blank" rel="external" class="url">{$comment.senderName}</a></b>&nbsp; on {$comment.intime|date_format:'%d.%m.%Y // %H:%M'} </h4>
					{else}
						<p class="name"><h4><b>{$comment.senderName}</b>&nbsp; on {$comment.intime|date_format:'%d.%m.%Y // %H:%M'} </h4>
					{/if}
				{/if}
					</p>
					<p class="date">
					[ <a href="{$SELF}#comment-{$comment.commentid}">{#link#}</a>

					{if (($data.intime > ($smarty.const.NOW - 60*60*24*$smarty.const.COMMENT_DAYS)) and ($comment.level < $smarty.const.COMMENT_TREE_DEPTH) and ($smarty.const.COMMENT_TREE)) or $smarty.session.admin}
					 : <a href="{$SELF}" onclick='quickreply("{$comment.commentid}"); return false;' >{#reply#}</a> 
					{/if}
					{dynamic}
						{if $smarty.session.admin}
							: <a href="{$SELF}dropcomment/{$comment.sortorder}/" onClick="return confirmLink(this,'{#youSure#}');">{#delete#}</a>
						{/if}
					{/dynamic}
					]</p>

					<div class="con"><p>{$comment.content}</p></div>
                    
				<div id="{$comment.commentid}"></div>

			</div>
		{/if}
	{/foreach}
	
	
	{if $data.intime > ($smarty.const.NOW - 60*60*24*$smarty.const.COMMENT_DAYS)}
	<div class="addCommentHeader" style="display: none;">(
        <a onClick="unhide('tabOpened'); unhide('addComment'); hide('tabClosed'); hide('quickAddComment');" id="tabClosed" style="cursor: pointer; cursor: hand; color: #69c; text-decoration:underline;">{#addComm#}</a>
        <a onClick="hide('tabOpened'); hide('addComment'); unhide('tabClosed');" id="tabOpened" style="cursor: pointer; cursor: hand; color: #69c; text-decoration:underline;display:none;">Close Comment Form</a>
	)
	</div>

		<form id="addComment" name="addComment" method="post" action="{$SELF}addcomment/">
		<div class="comments-form">
		<h3 id="respond">Comment Form</h3>
		{dynamic}
		{if !$smarty.session.admin}
			<p><input type="text" name="sender" id="comment-name" class="formid" value="{$smarty.cookies.sender}" size="27" tabindex="1" /> <label for="comment-name">{#name#} <strong class="required">(required)</strong></label></p>

			<p><input type="text" name="mail" id="comment-email" class="formemail" value="{$smarty.cookies.senderMail}" size="27" tabindex="2" /> <label for="comment-name">{#mail#}* <strong class="required">(required)</strong></label></p>

			<p><input type="text" name="url" id="comment-url" class="formuri" value="{$smarty.cookies.senderURL}" size="27" tabindex="3" /> <label for="comment-name">{#url#}</label></p>
		{/if}
		{/dynamic}

			<label for="comment">Comment :<br />
			<textarea name="comment" id="mainComment" cols="50" rows="8" tabindex="4">{dynamic}{$smarty.cookies.tPost}{/dynamic}</textarea></label> 
			<br />
			<label for="comment">{#htmltags#}<br />*{#note#}</label> 
			<br />

		{dynamic}
		{if $smarty.const.ANTISPAM and !$smarty.session.admin}
				<label for="antispam">{get_spam_challenge}<br />
				<input type="text" name="antispam" maxlength="6" style="width: 70px; {if $smarty.session.error}background:#f00; color:#fff;{/if}" value="" /></label> 
		{/if}
		{/dynamic}

		<input type="submit" name="send" id="submit" tabindex="5" class="button" value="{#sendComment#}" onClick="document.addComment.sendComment.disabled=true; this.value='{#pleaseWait#}'; document.getElementById('addComment').submit();" />

		<input type='hidden' name="replyto" value="" id="replyto" />
		</div>
		</form>


		<form id="quickAddComment" method="post" action="{$SELF}addcomment/" style="display: none;" name="quickAddComment">
			<div class="comments-form">
			<h3 id="respond">Comment Form</h3>
			{dynamic}
			{if !$smarty.session.admin}
				<p><input type="text" name="sender" id="comment-name" class="formid" value="{$smarty.cookies.sender}" size="27" tabindex="1" /> <label for="comment-name">{#name#} <strong class="required">(required)</strong></label></p>

				<p><input type="text" name="mail" id="comment-email" class="formemail" value="{$smarty.cookies.senderMail}" size="27" tabindex="2" /> <label for="comment-name">{#mail#}* <strong class="required">(required)</strong></label></p>

				<p><input type="text" name="url" id="comment-url" class="formuri" value="{$smarty.cookies.senderURL}" size="27" tabindex="3" /> <label for="comment-name">{#url#}</label></p>
			{/if}
			{/dynamic}

				<label for="comment">Comment :<br />
				<textarea name="comment" id="qcom" cols="50" rows="8" tabindex="4">{dynamic}{$smarty.cookies.tPost}{/dynamic}</textarea></label> 
				<br />
				<label for="comment">{#htmltags#}<br />*{#note#}</label> 
				<br />

				{dynamic}
				{if $smarty.const.ANTISPAM and !$smarty.session.admin}
						<label for="antispam">{get_spam_challenge}<br />
						<input type=text name="antispam" maxlength="6" class="myInput" style="width: 70px; {if $smarty.session.error}background:#f00; color:#fff;{/if}" value="" /></label> 
				{/if}
				{/dynamic}

				<input type="submit" name="send" id="submit" tabindex="5" class="button" value="{#sendComment#}" onClick="document.quickAddComment.sendComment.disabled=true; this.value='{#pleaseWait#}'; document.getElementById('quickAddComment').submit();" />

				<input type='hidden' name="replyto" value="" id="quickReplyID" />

			</div>
		</form>
    {/if}
</div>
{/if}